package koction.model.productComment;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Repository;

@Repository
public class ProductCommentDaoImpl implements ProductCommentDao{
	@Resource(name="sqlSessionTemplate")
	private SqlSessionTemplate sqlSessionTemplate;
	
	public int writeProductComment(ProductCommentVO pcvo){
		return this.sqlSessionTemplate.insert("productComment.writeProductComment",pcvo);
	}
	
	public List<ProductCommentVO> getProductCommentList(Map map){
		return this.sqlSessionTemplate.selectList("productComment.getProductCommentList",map);
	}
	
	public ProductCommentVO getCommentInfoByNo(int commentNo){
		return this.sqlSessionTemplate.selectOne("productComment.getCommentInfoByNo",commentNo);
	}
	public int updateRestep(ProductCommentVO pcvo){
		return this.sqlSessionTemplate.update("productComment.updateRestep",pcvo);
	}
	public int writeCommentReply(ProductCommentVO pcvo){
		return this.sqlSessionTemplate.insert("productComment.writeCommentReply",pcvo);
	}
	public int deleteCommentReply(int commentNo){
		return this.sqlSessionTemplate.delete("productComment.deleteCommentReply",commentNo);
	}
	public int modifyComment(Map map){
		return this.sqlSessionTemplate.update("productComment.modifyComment",map);
	}
	public int getProductCommentCount(int productId){
		return this.sqlSessionTemplate.selectOne("productComment.getProductCommentCount",productId);
	}
	public String getProductAvgStarRating(int productId){
		return this.sqlSessionTemplate.selectOne("productComment.getProductAvgStarRating",productId);
	}
	public int updateProductStarRating(Map map){
		return this.sqlSessionTemplate.update("productComment.updateProductStarRating",map);
	}
}
